package com.ruoyi.eqmonitor.controller;

import java.util.List;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.eqmonitor.domain.OptSewagePumpRange;
import com.ruoyi.eqmonitor.service.IOptSewagePumpRangeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import java.util.Arrays;

import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 污水厂泵站空间范围
 * @author ruoyi
 * @date 2023-01-06
 */
@RestController
@RequestMapping("/pumpRange")
public class OptSewagePumpRangeController extends BaseController{

    @Autowired
    private IOptSewagePumpRangeService optSewagePumpRangeService;

    /**
     * 查询污水厂泵站空间范围分页
     */
    @ApiOperation("查询污水厂泵站空间范围分页")
    @GetMapping("/page")
    public TableDataInfo<?> page(OptSewagePumpRange optSewagePumpRange){
        startPage();
        List<OptSewagePumpRange> list = optSewagePumpRangeService.selectOptSewagePumpRangeList(optSewagePumpRange);
        return getDataTable(list);
    }

    /**
     * 查询污水厂泵站空间范围列表
     */
    @ApiOperation("查询污水厂泵站空间范围列表")
    @GetMapping("/list")
    public AjaxResult list(OptSewagePumpRange optSewagePumpRange){
        List<OptSewagePumpRange> list = optSewagePumpRangeService.selectOptSewagePumpRangeList(optSewagePumpRange);
        return success(list);
    }

    /**
     * 查询污水厂泵站空间范围明细
     */
    @ApiOperation("查询污水厂泵站空间范围明细")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id){
        return AjaxResult.success(optSewagePumpRangeService.selectOptSewagePumpRangeById(id));
    }

    /**
     * 新增污水厂泵站空间范围
     */
    @ApiOperation("新增污水厂泵站空间范围")
    @Log(title = "污水厂泵站空间范围", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OptSewagePumpRange optSewagePumpRange){
        return toAjax(optSewagePumpRangeService.save(optSewagePumpRange));
    }

    /**
     * 修改污水厂泵站空间范围
     */
    @ApiOperation("修改污水厂泵站空间范围")
    @PutMapping
    public AjaxResult edit(@RequestBody OptSewagePumpRange optSewagePumpRange){
        return toAjax(optSewagePumpRangeService.updateById(optSewagePumpRange));
    }

    /**
     * 根据ids删除污水厂泵站空间范围
     */
    @ApiOperation("根据ids删除污水厂泵站空间范围")
    @Log(title = "污水厂泵站空间范围", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(optSewagePumpRangeService.removeByIds(Arrays.asList(ids)));
    }

}
